home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / ARRAY.BAS < prev    next >
BASIC Source File  |  1991-06-29  |  2KB  |  49 lines

  1. 100 CLS
  2. 110 DIM A$(50), I(50)
  3. 120 OPEN "I", 1, "phone.dat"' OPENs EXAMPLE.FIL as a source file to be read
  4. 130 LOCATE 9, 28: PRINT "READING FROM": LOCATE 9, 45: PRINT "WRITING  TO"
  5. 140 LOCATE 9, 45: PRINT "WRITING  TO"
  6. 150 LOCATE 10, 29: PRINT "INPUT FILE"
  7. 160 LOCATE 10, 45: PRINT "OUTPUT FILE"
  8. 170 LOCATE 11, 29: PRINT "~~~~~~~~~~"
  9. 180 LOCATE 11, 45: PRINT "~~~~~~~~~~~"
  10. 190 ' Reads from INPUT file begin...
  11. 200 FOR I = 1 TO 50
  12. 210   LINE INPUT #1, A$(I): LOCATE 12, 33: PRINT USING "####"; I' Reads In A$, as indexed by I
  13. 220   IF EOF(1) GOTO 240  ' Detects End of File, Dropping out of reads if fewer than 50 Records are detected
  14. 230 NEXT I
  15. 240 M = I' Sets M equal to highest value of I that was read into the Array...
  16. 250 CLOSE ' Closes File Number 1
  17. 260 BEEP
  18. 270 ' Writes to OUTPUT file begin...
  19. 280 OPEN "O", 1, "EXAMPLE.OUT"' OPENS EXAMPLE.OUT to write to it
  20. 290 FOR I = 1 TO M
  21. 300   PRINT #1, A$(I): LOCATE 12, 47: PRINT USING "####"; I
  22. 310 NEXT I
  23. 320 CLOSE
  24. 330 ' Screen Display of Indexed Array begins...  DISPLAYED FROM RAM!
  25. 340 BEEP
  26. 350 LOCATE 22, 25: PRINT "< Press ANY Key to Continue >"
  27. 360 I$ = INKEY$: IF I$ = "" THEN 360
  28. 370 CLS
  29. 380 FOR I = 1 TO M
  30. 390   L = I
  31. 400   IF I > 20 THEN L = I - 20
  32. 410   IF I > 40 THEN L = I - 40
  33. 420   LOCATE L, 1: PRINT A$(I): N = N + 1
  34. 430   IF N = 20 OR N = 40 THEN 440 ELSE GOTO 480
  35. 440   BEEP
  36. 450   LOCATE 22, 25: PRINT "< Press ANY Key to Continue >"
  37. 460   I$ = INKEY$: IF I$ = "" THEN 460
  38. 470   CLS
  39. 480 NEXT I
  40. 490 BEEP
  41. 500 LOCATE 22, 23: PRINT "< Want to See That Again (Y/N)? >"
  42. 510 I = 1: L = 0: N = 0
  43. 520 I$ = INKEY$: IF I$ = "" THEN 520' Waits for Keyboard Input...
  44. 530   IF I$ <> "Y" AND I$ <> "y" AND I$ <> "N" AND I$ <> "n" THEN 520' Edits Keyboard Input...
  45. 540   IF I$ = "Y" OR I$ = "y" THEN 370' If answer is yes then ARRAY is again displayed from RAM...
  46. 550   IF I$ = "N" OR I$ = "n" THEN 560' If answer is no, then program ends...
  47. 560 END
  48.  
  49.